import * as func from "./func.js"
import { getField } from "@/common.js"
export default {
  name: '',
  props: {
    formData:{
      type: Array,
      default: () => []
    },
    item: {
      type: Object,
      default: () => {}
    },
  },
  components:{},
  data(){
    return {
      operateList:[
        {field: 'disabled', name:'禁用', id: 1, isChecked:false},
        // {field: 'hide', name:'隐藏', id: 2, isChecked:false},
      ],
      checkList: [
        {field: 'required', name:'必填', id: 1, isChecked:false},
        // {field: 'regExp', name:'正则表达式', id: 2, isChecked:false},
        // {field: 'validator', name:'自定义校验规则', id: 3, isChecked:false},
      ]
    }
  },
  methods:{
    ...func,
  },
  computed:{
    checkType: function(){
      return getField(this.checkList, 'id', v => v.isChecked).join('')
    },
  },
  watch: {
    item: {
      handler: function(newVal, oldVal) {
        this.operateList = _.searchCover(this.operateList, v => v.field == 'disabled', v => ({...v, isChecked: newVal.disabled}))
        this.checkList = _.searchCover(this.checkList, v => v.field == 'required', v => ({...v, isChecked: newVal.required}))
      },
      deep: true, // 监听深层对象
      immediate: true, // 会在页 
    }
  },
  created(){
  },
  mounted(){
    
  },
}